<?php

namespace app\index\model;

use think\Model;

class SendOrder extends Model
{
    protected $pk = 'id';

    // public function getUserAttr($v, $data){
    //     return Member::where('id', $data['send_uid'])->value('memb_name');
    // }

    // public function getSenderAttr($v, $data){
    //     return Member::where('id', $data['sender_id'])->value('memb_name');
    // }

    public function sender(){
        return $this->belongsTo('Member', 'sender_id', 'memb_id')->bind(['sender_name'=>'memb_name', 'sender_phone'=>'memb_phone']);
    }

    /**
    * 检测当前二维码是否被发布订单
    */
    public function checkQrcode($condition){
        $isEx = $this->where('send_uid',session('user.id'))
        ->where('send_status', '<>', 3)
        ->where('send_qrcode_billcode', 'like', '%'. $condition .'%')
        ->find();
        if(empty($isEx)){
            return false;
        }else{
            return true;
        }
    }
}
